<%@ page import="entity.User" %>
<%@ page import="entity.Plate" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="Impl.adminDaoImpl" %>
<%@ page import="entity.Admin" %>
<%@ page import="entity.page.DetailPage" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>文章详情</title>
    <link rel="stylesheet" type="text/css" href="css/base.css">
    <link rel="stylesheet" type="text/css" href="css/amazeuinew.css">
    <link rel="stylesheet" type="text/css" href="css/indexcss.css">
    <link rel="stylesheet" type="text/css" href="css/postnew.css">
    <!-- Bootstrap -->
</head>

<script type="text/javascript">

    $(function () {
        $.get("/showBlockAjax", {},function (data, status) {
            // console.log(data);
            $('.module').html(data);
        })
    })
</script>
<body>
<%--<div class="top-bar" style="height: 50px;width: 100%;background-color:#242729;font-size: 23px;color: white;padding-top: 5px">--%>
<%--    <span style="margin-left: 20px;">论坛首页</span>--%>
<%--</div>--%>
<%@include file="header.jsp"%>
<%request.setCharacterEncoding("utf-8");%>
<%@include file="user_menubar.jsp"%>
<div class="content-wrapper">
    <div class="main">
        <div class="title">
            <%
                User u = (User) request.getSession().getAttribute("user");
                if (u != null && u.getUname().equals(request.getAttribute("author"))) {
//                    Integer sid = Integer.parseInt(request.getParameter("sid"));
//                    Integer tid = Integer.parseInt(request.getParameter("tid"));
            %>

            <h1 id="topicTitle">${detailPage.title}&nbsp;

                <a href="tomodify.jhtml?sid=<%=request.getAttribute("sid")%>&tid=<%=request.getAttribute("tid")%>&author=<%=request.getAttribute("author")%>&sname=<%=request.getAttribute("sname")%>">
                    【修改】</a> &nbsp;
                <a href="deletearticle.jhtml?sid=<%=request.getAttribute("sid")%>&tid=<%=request.getAttribute("tid")%>&sname=<%=request.getAttribute("sname")%>">【删除】</a></h1>

            <%} else {%>
            <h1 id="topicTitle">${detailPage.title}</h1>
            <%}%>
        </div>


        <!--文章主体-->
        <div class="article">
            <p>${detailPage.contents}</p>
        </div>

        <!--文章状态信息-->
        <div class="status">
            <span class="time">${detailPage.publishtime}</span><br/>
            <span class="time">最后修改时间：${detailPage.modifytime}</span>
            <span class="comm">
                    <span class=""></span>
<%--                    <span id="comt-count"></span>条评论--%>
                </span>
        </div>

        <div class="comt-title">
            <h2>评论列表</h2>
        </div>

        <div class="comt-list" style="border: #c5e88c solid 5px">

            <%
                ArrayList<DetailPage> replyPage = (ArrayList<DetailPage>) request.getAttribute("replyPage");
                if (replyPage.size() != 0) {
                    for (int i = 0; i < replyPage.size(); i++) {
            %>

            <div class=reply>
                <article class=am-comment>
                    <a href='#'>
                        <img class=am-comment-avatar src='static/img/head/1.gif' >
                    </a>
                    <div class=am-comment-main>
                        <header class=am-comment-hd>
                            <div class=am-comment-meta>
                                <a onClick="show_info('用户信息','/class_design/user/user-info.jsp?id=<%=user.getUid()%>','600','370') " class=am-comment-author target=_blank><%=replyPage.get(i).getAuthor()%></a>
                                回复于 <time><%=replyPage.get(i).getPublishtime()%></time>&nbsp;主题：<%=replyPage.get(i).getTitle()%>
                                <%if (u != null && u.getUname().equals(request.getAttribute("author"))) {%>
                                <a href="deletereply.jhtml?rid=<%=replyPage.get(i).getId()%>&sname=<%=request.getAttribute("sname")%>&sid=<%=request.getAttribute("sid")%>&tid=<%=request.getAttribute("tid")%>&author=<%=request.getAttribute("author")%>">删除</a>
                                <%}%>
                            </div>

                        </header>
                        <div class=am-comment-bd><%=replyPage.get(i).getContents()%></div>
                    </div>
                </article>
            </div>

            <%
                }
            } else {
            %>

            <div class="reply">
                暂无回复
            </div>

            <%}%>

        </div>
        <hr>
        <div>
            <h2 style="padding-bottom: 50px">评论</h2>
            <form method="post" action="/class_design/addreply.jhtml?sname=<%=request.getAttribute("sname")%>&sid=<%=request.getAttribute("sid")%>&rtid=<%=request.getAttribute("tid")%>&author=<%=request.getAttribute("author")%>">
                <h3>主题</h3>
                <ul>
                    <li style="border: #c5e88c solid 5px "><input type="text" value="" name="tname"></li>
                </ul>
                <h3>具体内容</h3>
                <ul>
                    <li style="border: #c5e88c solid 5px;height: 300px"><textarea type="text" value="" name="content" style="width: 1450px;height: 290px;"></textarea></li>
                </ul>
                <li style="padding: 20px 100px 20px 20px"><input type="submit" value="提交" style="float: right;font-size: 30px;background-color: #b3b3b3;border-radius: 5px;width: 100px"></li>
            </form>
        </div>

    </div>
</div>

<%@include file="footer.jsp"%>
</body>
</html>